driver can now handle multi-page hypercall stub areas.
Signed-off-by: Keir Fraser <keir@xensource.com>
xennet_set_sg(dev, 0);
/* We need checksum offload to enable scatter/gather and TSO. */
- if (!(dev->features & NETIF_F_ALL_CSUM))
+ if (!(dev->features & NETIF_F_IP_CSUM))
return;
if (!xennet_set_sg(dev, 1))
#define __STR(x) #x
#define STR(x) __STR(x)
+#ifdef CONFIG_XEN
+#define HYPERCALL_STR(name) \
+ "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
+#else
+#define HYPERCALL_STR(name) \
+ "mov hypercall_stubs,%%eax; " \
+ "add $("STR(__HYPERVISOR_##name)" * 32),%%eax; " \
+ "call *%%eax"
+#endif
+
#define _hypercall0(type, name) \
({ \
long __res; \
asm volatile ( \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res) \
: \
: "memory" ); \
({ \
long __res, __ign1; \
asm volatile ( \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res), "=b" (__ign1) \
: "1" ((long)(a1)) \
: "memory" ); \
({ \
long __res, __ign1, __ign2; \
asm volatile ( \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res), "=b" (__ign1), "=c" (__ign2) \
: "1" ((long)(a1)), "2" ((long)(a2)) \
: "memory" ); \
({ \
long __res, __ign1, __ign2, __ign3; \
asm volatile ( \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
"=d" (__ign3) \
: "1" ((long)(a1)), "2" ((long)(a2)), \
({ \
long __res, __ign1, __ign2, __ign3, __ign4; \
asm volatile ( \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
"=d" (__ign3), "=S" (__ign4) \
: "1" ((long)(a1)), "2" ((long)(a2)), \
({ \
long __res, __ign1, __ign2, __ign3, __ign4, __ign5; \
asm volatile ( \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res), "=b" (__ign1), "=c" (__ign2), \
"=d" (__ign3), "=S" (__ign4), "=D" (__ign5) \
: "1" ((long)(a1)), "2" ((long)(a2)), \
#define __STR(x) #x
#define STR(x) __STR(x)
+#ifdef CONFIG_XEN
+#define HYPERCALL_STR(name) \
+ "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"
+#else
+#define HYPERCALL_STR(name) \
+ "mov hypercall_stubs,%%rax; " \
+ "add $("STR(__HYPERVISOR_##name)" * 32),%%rax; " \
+ "call *%%rax"
+#endif
+
#define _hypercall0(type, name) \
({ \
long __res; \
asm volatile ( \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res) \
: \
: "memory" ); \
({ \
long __res, __ign1; \
asm volatile ( \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res), "=D" (__ign1) \
: "1" ((long)(a1)) \
: "memory" ); \
({ \
long __res, __ign1, __ign2; \
asm volatile ( \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res), "=D" (__ign1), "=S" (__ign2) \
: "1" ((long)(a1)), "2" ((long)(a2)) \
: "memory" ); \
({ \
long __res, __ign1, __ign2, __ign3; \
asm volatile ( \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
"=d" (__ign3) \
: "1" ((long)(a1)), "2" ((long)(a2)), \
long __res, __ign1, __ign2, __ign3; \
asm volatile ( \
"movq %7,%%r10; " \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
"=d" (__ign3) \
: "1" ((long)(a1)), "2" ((long)(a2)), \
long __res, __ign1, __ign2, __ign3; \
asm volatile ( \
"movq %7,%%r10; movq %8,%%r8; " \
- "call hypercall_page + ("STR(__HYPERVISOR_##name)" * 32)"\
+ HYPERCALL_STR(name) \
: "=a" (__res), "=D" (__ign1), "=S" (__ign2), \
"=d" (__ign3) \
: "1" ((long)(a1)), "2" ((long)(a2)), \
* Inform the balloon driver that it should allow some slop for device-driver
* memory activities.
*/
-extern void
+void
balloon_update_driver_allowance(
long delta);
/* Allocate an empty low-memory page range. */
-extern struct page *
+struct page *
balloon_alloc_empty_page_range(
unsigned long nr_pages);
/* Deallocate an empty page range, adding to the balloon. */
-extern void
+void
balloon_dealloc_empty_page_range(
struct page *page, unsigned long nr_pages);
-void balloon_release_driver_page(struct page *page);
+void
+balloon_release_driver_page(
+ struct page *page);
/*
* Prevent the balloon driver from changing the memory reservation during
#define DRV_VERSION "0.10"
#define DRV_RELDATE "03/03/2005"
-char hypercall_page[PAGE_SIZE];
-EXPORT_SYMBOL(hypercall_page);
+char *hypercall_stubs;
+EXPORT_SYMBOL(hypercall_stubs);
// Used to be xiaofeng.ling@intel.com
MODULE_AUTHOR("ssmith@xensource.com");
}
/* Lifted from hvmloader.c */
-static int get_hypercall_page(void)
+static int get_hypercall_stubs(void)
{
- void *tmp_hypercall_page;
- uint32_t eax, ebx, ecx, edx;
+ uint32_t eax, ebx, ecx, edx, pages, msr, order, i;
char signature[13];
cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
*(uint32_t*)(signature + 8) = edx;
signature[12] = 0;
- if (strcmp("XenVMMXenVMM", signature) || eax < 0x40000002) {
+ if (strcmp("XenVMMXenVMM", signature) || (eax < 0x40000002)) {
printk(KERN_WARNING
- "Detected Xen platform device but not Xen VMM? (sig %s, eax %x)\n",
+ "Detected Xen platform device but not Xen VMM?"
+ " (sig %s, eax %x)\n",
signature, eax);
return -EINVAL;
}
printk(KERN_INFO "Xen version %d.%d.\n", eax >> 16, eax & 0xffff);
- cpuid(0x40000002, &eax, &ebx, &ecx, &edx);
+ cpuid(0x40000002, &pages, &msr, &ecx, &edx);
- if (eax != 1) {
- printk(KERN_WARNING
- "This Xen version uses a %d page hypercall area,"
- "but these modules only support 1 page.\n",
- eax);
- return -EINVAL;
- }
+ i = pages - 1;
+ for (order = 0; i != 0; order++)
+ i >>= 1;
- tmp_hypercall_page = (void *)__get_free_page(GFP_KERNEL);
- if (!tmp_hypercall_page)
+ printk(KERN_INFO "Hypercall area is %u pages (order %u allocation)\n",
+ pages, order);
+
+ hypercall_stubs = (void *)__get_free_pages(GFP_KERNEL, order);
+ if (hypercall_stubs == NULL)
return -ENOMEM;
- memset(tmp_hypercall_page, 0xcc, PAGE_SIZE);
- if (wrmsr_safe(ebx, virt_to_phys(tmp_hypercall_page), 0))
- panic("Can't do wrmsr; not running on Xen?\n");
- memcpy(hypercall_page, tmp_hypercall_page, PAGE_SIZE);
- free_page((unsigned long)tmp_hypercall_page);
+
+ for (i = 0; i < pages; i++)
+ wrmsrl(ebx,
+ virt_to_phys(hypercall_stubs) + /* base address */
+ (i << PAGE_SHIFT) + /* offset of page @i */
+ i); /* request page @i */
return 0;
}
platform_mmio = mmio_addr;
platform_mmiolen = mmio_len;
- ret = get_hypercall_page();
+ ret = get_hypercall_stubs();
if (ret < 0)
goto out;
#include <asm/hypervisor.h>
#include "platform-pci.h"
-EXPORT_SYMBOL(xen_machphys_update);
void xen_machphys_update(unsigned long mfn, unsigned long pfn)
{
BUG();
}
+EXPORT_SYMBOL(xen_machphys_update);
void balloon_update_driver_allowance(long delta)
{
}
-
EXPORT_SYMBOL(balloon_update_driver_allowance);
+
+void balloon_release_driver_page(struct page *page)
+{
+}
+EXPORT_SYMBOL(balloon_release_driver_page);